Skip to content

Show PDF thumbnail on artifact admin change form (#1380)#1381

Merged
jonfroehlich merged 3 commits into
masterfrom
1380-artifact-thumbnail-preview
Jun 22, 2026
Merged

Show PDF thumbnail on artifact admin change form (#1380)#1381
jonfroehlich merged 3 commits into
masterfrom
1380-artifact-thumbnail-preview

Conversation

@jonfroehlich

@jonfroehlich jonfroehlich commented Jun 22, 2026

Copy link
Copy Markdown
Member

Closes #1380.

What & why

Editors previously only saw a "Currently: <filename>" link on the Publication / Talk / Poster admin change forms — no way to visually confirm the right PDF was attached. This adds a read-only PDF thumbnail preview to the Files fieldset.

How

  • New thumbnail_preview(self, obj) on ArtifactAdmin renders the auto-generated thumbnail as a ~220px-tall <img> via easy_thumbnails (same pipeline as the changelist get_display_thumbnail).
  • Injected into the 'Files' fieldset via ArtifactAdmin.get_fieldsets() so all three child admins get it without editing each fieldsets. Change view only (the Add form has no saved thumbnail yet).
  • Degrades to a text placeholder ("Save with a PDF attached to generate a thumbnail.") when there's no thumbnail or the source file is missing on disk (happens on the servers) — never 500s the change page.
  • Label is "PDF thumbnail:" per review feedback.

This composes cleanly with the #248 upload-guard work already on master (both touch ArtifactAdmin; merged in this branch).

Tests

website/tests/test_admin_thumbnail_preview.py (8 tests): img / placeholder / missing-file paths, None-obj guard, fieldset injection across all three admins (change-only, not add), no class-level fieldsets mutation, and a full change-form GET asserting the <img> renders unescaped.

Run: python manage.py test website.tests.test_admin_thumbnail_preview --settings=makeabilitylab.settings_test → 8/8 pass. Also re-ran #248 + changelist suites — no regressions.

Screenshots

image

🤖 Generated with Claude Code

jonfroehlich and others added 3 commits June 22, 2026 15:12
Editors only saw a "Currently: <filename>" link on the Publication / Talk /
Poster change forms, with no way to visually confirm the right PDF was
attached. Add a read-only `thumbnail_preview` field on ArtifactAdmin that
renders the auto-generated `thumbnail` as a ~220px-tall <img> via
easy_thumbnails (same pipeline as the changelist `get_display_thumbnail`).

- Injected into the 'Files' fieldset via `get_fieldsets()` on ArtifactAdmin, so
  all three child admins get it without editing each `fieldsets`. Change view
  only (the Add form has no saved thumbnail yet).
- Degrades to a text placeholder when there's no thumbnail or the source file
  is missing on disk (happens on the servers) rather than 500ing the page.
- Regression tests: img/placeholder/missing-file paths, fieldset injection
  across all three admins (change only, not add), no class-level mutation, and
  a full change-form GET asserting the <img> renders unescaped.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts:
#	website/admin/artifact_admin.py
#1380)

Per review feedback, "Thumbnail preview" → "PDF thumbnail" on the change form
(clearer that it's the PDF-derived thumbnail). Also updates the <img> alt text
and the regression test to match.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jonfroehlich jonfroehlich merged commit f66f10a into master Jun 22, 2026
3 checks passed
@jonfroehlich jonfroehlich deleted the 1380-artifact-thumbnail-preview branch June 22, 2026 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show artifact thumbnail preview on the admin change form

1 participant